package other.mvvm.activity.src.app_package.recyclerview

fun listMvvmAcitivityKt(
        applicationPackage:String?,
        activityClass:String,
        packageName:String,
        adapterName:String
)="""
package ${packageName}
import android.os.Bundle
import cn.logicalthinking.mvvm.base.BaseActivity
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import androidx.lifecycle.Observer
import ${applicationPackage}.R
import ${packageName}.${activityClass}ViewModel
import ${applicationPackage}.databinding.Activity${activityClass}Binding
class ${activityClass}Activity : BaseActivity<Activity${activityClass}Binding, ${activityClass}ViewModel>() {


    var adapter = ${adapterName}Adapter()

    override fun Activity${activityClass}Binding.initView() {
        
    }

    override fun initLiveDataObserve() {  
    
        mViewModel.msgList.observe(this, Observer {
            if (mViewModel.page == 1) {
                adapter.setNewInstance(it)
            } else {
                adapter.addData(it)
            }

            if (adapter.data.size == 0) {
                adapter.setEmptyView(R.layout.layout_list_empty)
            }
        })
    
    }

    override fun initData() {
    
        /**
         * 点击item事件
         **/
        adapter.setOnItemClickListener { _, view, position ->
            
        }
        
         adapter.loadMoreModule.isEnableLoadMoreIfNotFullPage = true
        
        //下拉加载更多
        adapter.loadMoreModule.setOnLoadMoreListener {
            mViewModel.page++ 
        } 
            
    }
    
   
    class ${adapterName}Adapter() :
        BaseQuickAdapter<${adapterName}, BaseViewHolder>(R.layout.item_list_${adapterName.toLowerCase()}), LoadMoreModule {

        override fun convert(holder: BaseViewHolder, item: ${adapterName}) {
          
        }
    }
} 
"""